#include "ag.h"
#include <rtl/print.h>
#include "drivers/simple/mmc.h"

#define MODULE "SECPOL"

VOID AgpDumpSecpol()
{
    N1_STATUS Status;
    PAG_PTE Pt = AgpLookupPartition(0, "seccfg");
    if (!Pt)
    {
        RtlPrintf("[%s] seccfg partition not found (try using mmc init 0)\n", MODULE);
        return;
    }

    RtlPrintf("[%s] found seccfg partition\n", MODULE);
    UINT8 Buffer[MMC_BLOCK_SIZE] ALIGNED(16);
    Status = MtkMmcRead(0, Buffer, 1, Pt->FirstLba);
    if (!N1_SUCCESS(Status))
    {
        RtlPrintf("[%s] read failed", MODULE);
        return;
    }

    UINT32 *Data32 = (UINT32 *)Buffer;
    if (Data32[0] != 0x4d4d4d4d)
    {
        RtlPrintf("[%s] invalid signature", MODULE);
        return;
    }

    RtlPrintf("[%s] SECCFG v%d found\n", MODULE, Data32[1]);
    RtlPrintf("[%s] Lock state is %d\n", MODULE, Data32[3]);
}
VOID AgpUnlockDevice()
{
    RtlPrintf("[%s] Currently unimplemented, sorry.\n", MODULE);
}
VOID AgpLockDevice()
{
    RtlPrintf("[%s] Currently unimplemented, sorry.\n", MODULE);
}